<template>
  <div>
    <homeT :arrzhuyao="arrzhuyao"></homeT>
    <homeT :arr="arr"></homeT>
    <homeT :arrnew="arrnew"></homeT>
  </div>
</template>
<script>
import axios from "axios";
import homeT from "./8-19home2.vue";
export default {
  components: {
    homeT,
  },
  data() {
    return {
      arr: [],
      arrzhuyao: [],
      arrnew: [],
    };
  },
  mounted() {
    axios.get("https://jd.itying.com/api/pcate").then((res) => {
      this.arr = res.data.result;
    });
    axios.get(" https://jd.itying.com/api/focus").then((res) => {
      this.arrzhuyao = res.data.result;
      this.arrzhuyao.forEach((item) => {
        item.pic = "https://jd.itying.com/" + item.pic.split("\\").join("/");
        return item.pic;
      });
    });
  },
  methods: {
    pinlei(item) {
      console.log(this.arr[item]);
      axios
        .get("https://jd.itying.com/api/plist?cid=" + this.arr[item]._id)
        .then((res) => {
          this.arrnew = res.data.result;
          console.log(this.arrnew);
          this.arrnew.forEach((item) => {
            item.pic =
              "https://jd.itying.com/" + item.pic.split("\\").join("/");
            return item.pic;
          });
        });
    },
    tiaozhuan(item) {
      console.log(item);
    },
  },
};
</script>
